package org.canaan.http.core;

import org.apache.http.client.config.RequestConfig;
import org.canaan.http.HttpBuilder;
import org.canaan.http.core.single.RequestConfigFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Canaan
 * @date 2017/8/9
 */
public abstract class AbstractHttpBuilder implements HttpBuilder{

    protected final Map<String, String> header; //请求头
    protected final Map<String, Object> cookies;     //设置cookies
    protected       RequestConfig       requestConfig; //请求参数设置
    protected       int                 repeatTimes;      //重复执行次数,默认3次
    protected       boolean             hasCookies; //是否返回cookies
    protected       boolean             isSingle; //是否为单例
    protected       boolean             autoClose; //是否自动关闭


    protected AbstractHttpBuilder() {
        //设置默认头部信息
        this.header = new HashMap<>();
        this.appendHeader("Connection", "keep-alive");
        this.appendHeader("Accept-Language", "zh-CN,zh;q=0.8");
        this.appendHeader("Accept-Encoding", "gzip, deflate");
        this.appendHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
        this.cookies = new HashMap<>();
        this.repeatTimes = 3;
        this.isSingle = true;
        this.hasCookies = false;
        this.autoClose = true;
    }

}
